package com.sohoometer.datamodify;

import java.io.FileOutputStream;
import java.io.PrintStream;

import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SchedulerMetaData;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

public class ModifyData {
	public static void main(String[] args) throws Exception {
		FileOutputStream fileOutputStream = new FileOutputStream("d:/dataMotify.log",true);
		System.setOut(new PrintStream(fileOutputStream));
		System.setErr(new PrintStream(fileOutputStream) );
		JobBuilder jobBuilder = JobBuilder.newJob(JobImpl.class);
		JobDetail job = jobBuilder.withIdentity("test").build();
		String cornExpression = "1 3 * * * ? *";
		try {
//			cornExpression = DataDao.properties.getProperty("cornExpression");
		} catch (Exception e) {
		}
		CronScheduleBuilder scheduleBuilder = CronScheduleBuilder
				.cronSchedule(cornExpression);// 每隔10分钟跑一次
		TriggerBuilder<CronTrigger> triggerBuilder = TriggerBuilder
				.newTrigger().forJob(job).withIdentity("test3").withSchedule(scheduleBuilder).startNow();
		CronTrigger trigger = triggerBuilder.build();
		StdSchedulerFactory factory = new StdSchedulerFactory();
		Scheduler scheduler = factory.getScheduler();
		SchedulerMetaData metaData = scheduler.getMetaData();
		scheduler.scheduleJob(job, trigger);
		scheduler.start();
	}

}
